package com.itheima.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.entity.OrderDetails;
import com.itheima.entity.Orders;
import com.itheima.jsonresult.JsonResult;
import com.itheima.service.OrderDetailsService;
import com.itheima.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author linying
 * @since 2022-10-13
 */
@RestController
@RequestMapping("/order")
public class OrdersController {

    @Autowired
    private OrdersService orderService;

    /**
     *提交订单
     * @param orders
     * @return
     */
    @PostMapping("submit")
    public JsonResult submit(@RequestBody Orders orders){
        return orderService.submit(orders);
    }

    /**
     * 订单列表
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/userPage")
    public JsonResult userPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize){
        return orderService.userPage(page,pageSize);
    }

}
